<%--
  Created by IntelliJ IDEA.
  User: zzf
  Date: 2021/1/7
  Time: 16:20
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ include file="/public/header/permissionCommon.jspf" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>长护险服务机构管理</title>
    <c:set var="path" value="${pageContext.request.contextPath}" scope="page"/>
    <%--<link rel="stylesheet" type="text/css" href="${path}/lib/layui/css/layui.css">--%>
    <style type="text/css">
        .layui-table-tips-main{display:none}
        .layui-table-tips-c{display:none}
        .layui-table-grid-down {display: none;}
    </style>
</head>

<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <!-- 头部和左侧导航-->
    <div id="header"></div>
    <%--<!--右侧主体区域-->--%>
    <div class="layui-body" >
        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
            <ul class="layui-tab-title">
                <li class="layui-this">服务机构信息</li>
                <li>历史变更记录</li>
            </ul>
            <div class="layui-tab-content">
                <%-----------护理机构信息显示-----------%>
                <div id="DepartmentInfoDiv" class="layui-tab-item layui-show">
                    <%-----------搜索 & 文件上传导出 功能-----------%>
                    <div class="SearchLoadDepartment" style="font-size: small">
                        <%------------搜索功能---------------%>
                        服务机构名称：
                        <div class="layui-inline">
                            <input class="layui-input" name="department_name" id="department_name" autocomplete="off" style="height: 30px;width:100px;margin-right: 10px">
                        </div>
                        区内编码：
                        <div class="layui-inline">
                            <input class="layui-input" name="department_region_code" id="department_region_code" autocomplete="off" style="height: 30px;width:100px;margin-right: 10px">
                        </div>
                        状态：
                        <div class="layui-input-inline layui-form" style="width: 150px">
                            <select name="statusSearch" id="statusSearch" lay-filter="statusSearch" class="select">
                                <option value="">请选择状态类型</option>
                                <option value="有效">有效</option>
                                <option value="无效">无效</option>
                            </select>
                        </div>

                        <div class="layui-inline">
                            <button class="searchBtn" data-type="reload1" style="margin-left:10px;height:30px;width:85px;background-color: #009688;color: white;border: none;border-radius: 5px">
                                <i class="layui-icon layui-icon-search"></i>
                                <div class="layui-inline" style="font-size: small;text-align:center;margin-top: -6px;margin-left: 5px;margin-right: 5px">搜 索</div>
                            </button>
                        </div>
                        <%-------------文件导出-------------%>
                        <div class="layui-inline" style="float: right">
                            <button class="layui-btn layui-btn-sm" id="exportExcel" name="exportExcel" style="width: 100px;float: right;border-radius: 5px;margin-left: 5px">
                                <i class="layui-icon layui-icon-export"></i>
                                <div class="layui-inline" style="font-size: small;text-align:center;margin-top: -3px">导出文件</div>
                            </button>
                        </div>
                        <%--------------文件导入-------------%>
                        <div class="layui-inline" style="float: right">
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-normal" id="uploadExcel" style="width: 100px;float: right;border-radius: 5px;margin-left: 5px;font-size:small ">
                                <i class="layui-icon layui-icon-upload-drag"></i>
                                &nbsp上传文件
                            </button>
                        </div>
                            <%--新增--%>
                            <div class="layui-inline" style="float: right">
                                <button class="searchBtn layui-btn layui-btn-sm"  data-type="Add" style="width: 100px;float: right;border-radius: 5px;margin-left: 5px;font-size:small; margin-right: 10px;background-color: #009688">
                                    <i class="layui-icon layui-icon-export"></i>
                                    <div class="layui-inline" style="font-size: small;text-align:center;margin-top: -3px">新 增</div>
                                </button>
                            </div>

                    </div>

                    <%----------- 信息表格 显示------------%>
                    <table class="layui-hide" id="departmentInfoList" lay-filter="department" ></table>
                </div>
                <%-----------护理机构 变更 信息显示-----------%>
                <div id="DepartmentInfoChangedDiv" class="layui-tab-item">
                    <%-----------搜索 & 文件导出 功能-----------%>
                    <div class="SearchLoadDepartment" style="font-size: small">
                        <%------------搜索功能---------------%>
                        服务机构名称：
                        <div class="layui-inline">
                            <input class="layui-input" name="nameSearch" id="nameSearch" autocomplete="off" style="height: 30px;width:100px;margin-right: 10px">
                        </div>
                        结算代码：
                        <div class="layui-inline">
                            <input class="layui-input" name="settleCodeSearch" id="settleCodeSearch" autocomplete="off" style="height: 30px;width:100px;margin-right: 10px">
                        </div>
                        变更字段名称：
                        <div class="layui-input-inline layui-form" style="width: 150px">
                            <input class="layui-input" name="titleSearch" id="titleSearch" autocomplete="off" style="height: 30px;width:100px;margin-right: 10px">
                        </div>

                        <div class="layui-inline">
                            <button class="searchBtn" data-type="reload2" style="margin-left:10px;height:30px;width:85px;background-color: #009688;color: white;border: none;border-radius: 5px">
                                <i class="layui-icon layui-icon-search"></i>
                                <div class="layui-inline" style="font-size: small;text-align:center;margin-top: -6px;margin-left: 5px;margin-right: 5px">搜 索</div>
                            </button>
                        </div>
                        <%-------------文件导出-------------%>
                        <div class="layui-inline" style="float: right">
                            <button class="layui-btn layui-btn-sm" id="exportChangedExcel" name="exportChangedExcel" style="width: 100px;float: right;border-radius: 5px;margin-left: 5px">
                                <i class="layui-icon layui-icon-export"></i>
                                <div class="layui-inline" style="font-size: small;text-align:center;margin-top: -3px">导出文件</div>
                            </button>
                        </div>
                    </div>
                    <%----------- 变更表格 显示------------%>
                    <table class="layui-hide" id="departmentInfoChangedList" lay-filter="departmentChanged" ></table>
                </div>
            </div>
        </div>
    </div>
    <!--底部-->
    <div id="footer"></div>
    <%--<script src="${webPath}/js/permission/auth/permList.js"></script>--%>
    <script>
        $("#header").load("${webPath}/publicPages/permission/fragments/header.jsp");
        $("#footer").load("${webPath}/publicPages/permission/fragments/footer.jsp");
    </script>
    <!--------- 信息页面 表格 -------------->
    <script type="text/javascript" src="${webPath}/js/basicInfo/ServiceDepartment.js"></script>
    <%-------------编辑删除框--------------%>
    <%--查看页面的编辑框--%>
    <script type="text/html" id="Check_Edit_Del">
        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </script>
    <%--历史变更页面的编辑框--%>
    <script type="text/html" id="Check">
        <a class="layui-btn layui-btn-xs" lay-event="detail" style="margin-top: 5px">查看</a>
    </script>

    <%--------------------- 信息页面的查看功能 ---------------%>
    <script type="text/javascript" src="${webPath}/js/utils.js"></script>
    <div class="departmentDetail" id="DepartmentDetail" style="display: none">
        <form class="layui-form layui-form-pane" style="margin-top: 20px;margin-left: 10px;margin-right: 10px;">
            <div class="layui-form-item">
                <div class="layui-col-xs6 ">
                    <label class="layui-form-label" >机构名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="department_name" value={department_name} class="layui-input" readonly="readonly">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">联系方式</label>
                    <div class="layui-input-block">
                        <input type="text" name="department_phone_number" value={department_phone_number} class="layui-input" readonly="readonly">
                    </div>
                </div>
            </div>
            <div class="layui-form-item"><%--ok--%>
                <label class="layui-form-label">现在地址</label>
                <div class="layui-input-block">
                    <input type="text" name="department_address" value={department_address} class="layui-input" readonly="readonly">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <label class="layui-form-label">法人</label>
                    <div class="layui-input-block">
                        <input type="text" name="department_corporate" value={department_corporate} class="layui-input" readonly="readonly">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">区内编码</label>
                    <div class="layui-input-block">
                        <input type="text" name="department_settlement_code" value={department_settlement_code} class="layui-input" readonly="readonly">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="height: 75px;white-space:pre-line!important;">交易代码下发通知书日期</label>
                <div class="layui-input-block">
                    <input style="height: 75px;" type="date" name="department_notification_date" value={department_notification_date} class="layui-input" readonly="readonly">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="height: 55px;white-space:pre-line!important;">首次可结算日期</label>
                <div class="layui-input-block">
                    <input style="height: 55px;" type="date" name="department_first_settle_date" value={department_first_settle_date} class="layui-input" readonly="readonly">
                </div>
            </div>
            <div class="layui-form-item" >
                <div class="layui-col-xs6" >
                    <label class="layui-form-label" >结算代码</label>
                    <div class="layui-input-block">
                        <input class="layui-input" type="text" name="department_settlement_code" value={department_settlement_code} readonly="readonly" >
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">结算范围</label>
                    <div class="layui-input-block">
                        <input type="text" name="department_settlement_scope" value={department_settlement_scope} class="layui-input" readonly="readonly">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <label class="layui-form-label">创建时间</label>
                    <div class="layui-input-block">
                        <input type="datetime-local" name="department_first_time" readonly="readonly" value={department_first_time} step="1" class="layui-input">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">修改时间</label>
                    <div class="layui-input-block">
                        <input type="datetime-local" name="department_change_time" readonly="readonly" value={department_change_time} step="1" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">状态</label>
                <div class="layui-input-block">
                    <input type="text" name="department_status" value={department_status} class="layui-input" readonly="readonly">
                </div>
            </div>
        </form>
    </div>
    <%--------------------- 信息页面的编辑功能 ---------------%>
    <div class="editDepartment" id="DepartmentEdit" style="display: none;">
        <form class="layui-form layui-form-pane" id="DepartmentForm" style="margin-top: 20px;margin-left: 10px;margin-right: 10px;" action="">
            <div class="layui-form-item">
                <div class="layui-col-xs6 ">
                    <label class="layui-form-label"><div class="layui-inline"style="color: red">*</div>机构名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="department_name" value={department_name} lay-verify="required" class="layui-input">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label"><div class="layui-inline"style="color: red">*</div>联系方式</label>
                    <div class="layui-input-block">
                        <input type="text" name="department_phone_number" value={department_phone_number} lay-verify="required" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">现在地址</label>
                <div class="layui-input-block">
                    <input type="text" name="department_address" value={department_address} class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <label class="layui-form-label"><div class="layui-inline"style="color: red">*</div>法人</label>
                    <div class="layui-input-block">
                        <input type="text" name="department_corporate" value={department_corporate} lay-verify="required" class="layui-input">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">区内编码</label>
                    <div class="layui-input-block">
                        <input type="text" name="department_region_code" value={department_region_code} class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="height: 75px;white-space:pre-line!important;">交易代码下发通知书日期</label>
                <div class="layui-input-block">
                    <input style="height: 75px;" type="date" name="department_notification_date" value={department_notification_date} class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="height: 75px;white-space:pre-line!important;">启变日期</label>
                <div class="layui-input-block">
                    <input style="height: 75px;" type="date" name="start_change_date" value={start_change_date} class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="height: 55px;white-space:pre-line!important;">首次可结算日期</label>
                <div class="layui-input-block">
                    <input style="height: 55px;" type="date" name="department_first_settle_date" value={department_first_settle_date} class="layui-input">
                </div>
            </div>
            <div class="layui-form-item" >
                <div class="layui-col-xs6" >
                    <label class="layui-form-label"><div class="layui-inline"style="color: red">*</div>结算代码</label>
                    <div class="layui-input-block">
                        <input class="layui-input" type="text" name="department_settlement_code" lay-verify="required" value={department_settlement_code} >
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">结算范围</label>
                    <div class="layui-input-block">
                        <input type="text" name="department_settlement_scope" value={department_settlement_scope} class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <label class="layui-form-label">创建时间</label>
                    <div class="layui-input-block">
                        <input type="datetime-local" name="department_first_time" class="layui-input" value={department_first_time} step="1">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">修改时间</label>
                    <div class="layui-input-block">
                        <input type="datetime-local" name="department_change_time" class="layui-input" value={department_change_time} step="1" >
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><div class="layui-inline"style="color: red">*</div>状态</label>
                <div class="layui-input-block">
                    <select name="department_status" id="department_status">
                        <option value="有效" {select1}>有效</option>
                        <option value="无效" {select2}>无效</option>
                    </select>
                </div>
            </div>

            <div class="layui-form-item" style="display: none">
                <label class="layui-form-label">序号</label>
                <div class="layui-input-block">
                    <input type="text" name="id" value={id} class="layui-input" readonly="readonly">
                </div>
            </div>
            <div class="layui-form-item" align="center" style="margin-top: 20px;margin-bottom: 20px">
                <button type="submit" class="layui-btn" lay-submit="" id="handin" lay-filter="handin" style="margin-right: 20px">
                    <div style="font-weight: bold;font-size: medium">立 即 提 交</div>
                </button>
                <button class="layui-btn layui-btn-primary" style="width:100px" type="button">
                    <div style="font-weight: bold;font-size: medium" onclick="javascript:history.go(-1)">取&nbsp&nbsp&nbsp&nbsp消</div>
                </button>
            </div>
        </form>
    </div>

    <%--新增机构--%>
    <div class="editDepartment" id="AddDepartment" style="display: none;">
        <form class="layui-form layui-form-pane" id="AddDepartmentForm" style="margin-top: 20px;margin-left: 10px;margin-right: 10px;" action="">
            <div class="layui-form-item">
                <div class="layui-col-xs6 ">
                    <label class="layui-form-label"><div class="layui-inline"style="color: red">*</div>机构名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="department_name" value={department_name} lay-verify="required" class="layui-input">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label"><div class="layui-inline"style="color: red">*</div>联系方式</label>
                    <div class="layui-input-block">
                        <input type="text" name="department_phone_number" value={department_phone_number} lay-verify="required" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">现在地址</label>
                <div class="layui-input-block">
                    <input type="text" name="department_address" value={department_address} class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <label class="layui-form-label"><div class="layui-inline"style="color: red">*</div>法人</label>
                    <div class="layui-input-block">
                        <input type="text" name="department_corporate" value={department_corporate} lay-verify="required" class="layui-input">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">区内编码</label>
                    <div class="layui-input-block">
                        <input type="text" name="department_region_code" value={department_region_code} class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="height: 75px;white-space:pre-line!important;">交易代码下发通知书日期</label>
                <div class="layui-input-block">
                    <input style="height: 75px;" type="date" name="department_notification_date" value={department_notification_date} class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="height: 55px;white-space:pre-line!important;">首次可结算日期</label>
                <div class="layui-input-block">
                    <input style="height: 55px;" type="date" name="department_first_settle_date" value={department_first_settle_date} class="layui-input">
                </div>
            </div>
            <div class="layui-form-item" >
                <div class="layui-col-xs6" >
                    <label class="layui-form-label"><div class="layui-inline"style="color: red">*</div>结算代码</label>
                    <div class="layui-input-block">
                        <input class="layui-input" type="text" name="department_settlement_code" lay-verify="required" value={department_settlement_code} >
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">结算范围</label>
                    <div class="layui-input-block">
                        <input type="text" name="department_settlement_scope" value={department_settlement_scope} class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-col-xs6">
                    <label class="layui-form-label">创建时间</label>
                    <div class="layui-input-block">
                        <input type="datetime-local" name="department_first_time" class="layui-input" value={department_first_time} step="1">
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">修改时间</label>
                    <div class="layui-input-block">
                        <input type="datetime-local" name="department_change_time" class="layui-input" value={department_change_time} step="1" >
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><div class="layui-inline"style="color: red">*</div>状态</label>
                <div class="layui-input-block">
                    <select name="department_status" id="Adddepartment_status">
                        <option value="有效" {select1}>有效</option>
                        <option value="无效" {select2}>无效</option>
                    </select>
                </div>
            </div>

            <div class="layui-form-item" style="display: none">
                <label class="layui-form-label">序号</label>
                <div class="layui-input-block">
                    <input type="text" name="id" value={id} class="layui-input" readonly="readonly">
                </div>
            </div>
            <div class="layui-form-item" align="center" style="margin-top: 20px;margin-bottom: 20px">
                <button type="submit" class="layui-btn" lay-submit="" id="handAdd" lay-filter="handAdd" style="margin-right: 20px">
                    <div style="font-weight: bold;font-size: medium">立 即 提 交</div>
                </button>
                <button class="layui-btn layui-btn-primary" style="width:100px" type="button">
                    <div style="font-weight: bold;font-size: medium" onclick="javascript:history.go(-1)">取&nbsp&nbsp&nbsp&nbsp消</div>
                </button>
            </div>
        </form>
    </div>
    <script>
        layui.use('form', function(){
            var form = layui.form;
            form.on('submit(handin)', function(data){
                console.log("开始提交");
                console.log(data.field);
                $.ajax({
                    url:'/department/updateDepartment',
                    method:'POST',
                    data:data.field,
                    dataType:'JSON',
                    success:function(res){
                        console.log("res.msg："+res.msg);
                        if(res.msg=="ok"){
                            console.log("成功提交"+data.field);
                            layer.msg("提交成功",{icon: 1, time: 1500},function(){location.reload();}); //提交成功后刷新页面
                            // alert("提交成功");
                        }else{
                            console.log("请确保“结算代码”输入正确"+data.field);
                            layer.msg("请确保“结算代码”输入正确",{ icon: 5,anim: 6,offset: "auto"});
                        }
                    },
                    error:function (data) {
                        console.log("提交失败",data);
                    }
                });
                return false;
            })
        })
    </script>
    <%--新增机构js--%>
    <script>
        layui.use('form', function(){
            var form = layui.form;
            form.on('submit(handAdd)', function(data){
                console.log("开始提交");
                console.log(data.field);
                $.ajax({
                    url:'/department/AddDepartment',
                    method:'POST',
                    data:data.field,
                    dataType:'JSON',
                    success:function(res){
                        console.log("res.msg："+res.msg);
                        if(res.msg=="ok"){
                            console.log("成功提交"+data.field);
                            layer.msg("提交成功",{icon: 1, time: 1500},function(){location.reload();}); //提交成功后刷新页面
                            // alert("提交成功");
                        }else{
                            console.log("请确保“结算代码”输入正确"+data.field);
                            layer.msg("请确保“结算代码”输入正确",{ icon: 5,anim: 6,offset: "auto"});
                        }
                    },
                    error:function (data) {
                        console.log("提交失败",data);
                    }
                });
                return false;
            })
        })
    </script>
    <%------------------ 历史变更页面的查看功能 ---------------%>
    <div class="departmentDetail" id="DepartmentChangedDetail" style="display: none">
        <form class="layui-form layui-form-pane" style="margin-top: 20px;margin-left: 10px;margin-right: 10px;">
            <div class="layui-form-item">
                <label class="layui-form-label">机构名称
                </label>
                <div class="layui-input-block">
                    <input type="text" name="department_name" value={department_name} class="layui-input" readonly="readonly">
                </div>
            </div>
            <div class="layui-form-item" >
                <label class="layui-form-label">
                    <div >结算代码</div>
                </label>
                <div class="layui-input-block">
                    <input class="layui-input"type="text" name="department_settlement_code" value={department_settlement_code} readonly="readonly" >
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">变更时间</label>
                <div class="layui-input-block">
                    <input type="datetime-local" step="1"  name="department_change_time" readonly="readonly" value={department_change_time} class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">启变日期</label>
                <div class="layui-input-block">
                    <input type="date" step="1"  name="start_change_date" readonly="readonly" value={start_change_date} class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="height: 55px;white-space:pre-line!important;">变更字段名称</label>
                <div class="layui-input-block">
                    <input type="text" style="height: 55px;" step="1"  name="department_changed_title" value={department_changed_title} class="layui-input" readonly="readonly">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="height: 55px;white-space:pre-line!important;">变更前的内容</label>
                <div class="layui-input-block">
                    <input type="text" style="height: 55px;" name="department_history_content" value={department_history_content} class="layui-input" readonly="readonly">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="height: 55px;white-space:pre-line!important;">变更后的内容</label>
                <div class="layui-input-block">
                    <input type="text" style="height: 55px;"   name="department_new_content" value={department_new_content} class="layui-input" readonly="readonly">
                </div>
            </div>

        </form>
    </div>
    <%------------------- 信息页面 EXCEL 文件上传------------------%>
    <script type="text/javascript">
        layui.use('upload', function(){
            var $ = layui.jquery
                ,upload = layui.upload;
            upload.render({
                elem: '#uploadExcel'
                ,url: '/department/InputExcel' //改成您自己的上传接口
                ,accept: 'file' //普通文件
                ,exts: 'xls|xlsx' //只允许上传压缩文件
                ,done: function(res){
                    console.log(res);
                    if(res.msg=="ok"){
                        layer.msg("文件导入成功",{icon: 1, time: 1500},function(){location.reload();});
                        // alert("文件导入成功");
                    }else{
                        layer.msg("文件导入失败",{icon: 2, time: 1500},function(){location.reload();});
                        // alert("文件导入失败失败");
                    }
                }
                ,error:function(){
                    layer.msg("文件导入失败",{icon: 2, time: 1500},function(){location.reload();});
                }
            });
        })
    </script>
    <%------------------- 信息页面 EXCEL 文件导出------------------%>
    <script type="text/javascript">
        layui.config({//配置并导入excel插件
            base: '${base}/js/layui_exts/'
        }).use([ 'excel', 'layer'], function() {
            var $ = layui.$;
            var layer = layui.layer;
            var excel = layui.excel;
            $('#exportExcel').on('click', function(){
                console.log("触发导出按钮");
                var send_name = $('#department_name');
                var send_code = $('#department_region_code');
                var send_status=$('#statusSearch');
                // console.log("导出：搜索的机构是"+send_name.val());
                // console.log("导出：搜索的区内编码是"+send_code.val());
                // console.log("导出：搜索的状态是"+send_status.val());
                layer.confirm('是否确认导出', function(index) {
                    $.ajax({
                        url: '/department/ExportAllInfo'
                        ,method:'post'
                        ,data: {
                            departmentName: send_name.val(),
                            regionCode: send_code.val(),
                            status:send_status.val()
                        }
                        , dataType: 'json'
                        , success(res) {
                            var data = res;
                            console.log(res);
                            layer.close(index);
                            data = excel.filterExportData(data, [
                                'department_name'
                                , 'department_phone_number'
                                , 'department_address'
                                , 'department_settlement_scope'
                                , 'department_first_settle_date'
                                , 'department_notification_date'
                                , 'department_corporate'
                                , 'department_settlement_code'
                                , 'department_region_code'
                                , 'department_first_time'
                                , 'department_change_time'
                                , 'department_status'
                            ]);
                            data.unshift({
                                department_name: "机构名称", department_phone_number: "机构电话",
                                department_address: '机构地址', department_settlement_scope: "结算范围",
                                department_first_settle_date: "首次可结算日期", department_notification_date: '交易代码下发通知书日期',
                                department_corporate: "法人", department_settlement_code: "结算代码（唯一11位）",
                                department_region_code: '区内编码', department_first_time: "创建时间",
                                department_change_time: "修改时间", department_status: "状态"
                            });
                            // var timestart = Date.now();
                            excel.exportExcel(data, '服务机构信息导出--' + new Date().toLocaleString() + '.xlsx', 'xlsx');
                            //	var timeend = Date.now();
                            //	var spent = (timeend - timestart) / 1000;
                            //	console.log('单纯导出耗时 '+spent+' s');
                        }
                        , error() {
                            layer.alert('获取数据失败，请检查是否部署在本地服务器环境下');
                        }
                    });
                });
            });
        });
    </script>
    <%------------------- 变更页面 EXCEL 文件导出------------------%>
    <script type="text/javascript">
        layui.config({//配置并导入excel插件
            base: '${base}/js/layui_exts/'
        }).use([ 'excel', 'layer'], function() {
            var $ = layui.$;
            var layer = layui.layer;
            var excel = layui.excel;
            $('#exportChangedExcel').on('click', function(){
                console.log("触发导出按钮");
                var send_name = $('#nameSearch');
                var send_code = $('#settleCodeSearch');
                var send_title=$('#titleSearch');
                console.log("导出：搜索的机构是"+send_name.val());
                console.log("导出：搜索的结算代码是"+send_code.val());
                console.log("导出：搜索的名称是"+send_title.val());
                layer.confirm('是否确认导出', function(index) {
                    $.ajax({
                        url: '/department/ExportAllChangedInfo'
                        ,method:'post'
                        ,data: {
                            nameSearch: send_name.val(),
                            settleCodeSearch: send_code.val(),
                            titleSearch:send_title.val()
                        }
                        , dataType: 'json'
                        , success(res) {
                            var data = res;
                            console.log(res);
                            layer.close(index);
                            data = excel.filterExportData(data, [
                                'department_name'
                                , 'department_settlement_code'
                                , 'department_change_time'
                                , 'department_changed_title'
                                , 'department_history_content'
                                , 'department_new_content'

                            ]);
                            data.unshift({
                                department_name: "机构名称", department_settlement_code: "结算代码（唯一11位）",
                                department_change_time: "修改时间",department_changed_title:"变更字段名称",
                                department_history_content:"变更前内容",department_new_content:"变更后内容"
                            });
                            excel.exportExcel(data, '服务机构变更信息导出--' + new Date().toLocaleString() + '.xlsx', 'xlsx');
                        }
                        , error() {
                            layer.alert('获取数据失败，请检查是否部署在本地服务器环境下');
                        }
                    });
                });
            });
        });
    </script>
</div>
</body>
</html>


